package com.letoken.platform.repo.app.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.letoken.platform.repo.admin.req.user.QueryAccelerateListReq;
import com.letoken.platform.repo.admin.req.user.QueryCirculationListReq;
import com.letoken.platform.repo.admin.req.user.QueryIssueListReq;
import com.letoken.platform.repo.admin.req.user.QueryLineChartReq;
import com.letoken.platform.repo.admin.res.user.*;
import com.letoken.platform.repo.app.po.AppUserIssue;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * Le账户-用户铸币发行信息 Mapper 接口
 * </p>
 *
 * @author 作者
 * @since 2022-12-10
 */
public interface AppUserIssueMapper extends BaseMapper<AppUserIssue> {

    int updateUserIssueByUseIid(@Param("issueAmount") BigDecimal issueAmount,@Param("circulationAmount")BigDecimal circulationAmount,@Param("circulationRemain")BigDecimal circulationRemain,@Param("userId")Integer userId,@Param("version")Integer version,@Param("countDown")Integer countDown,@Param("rewardTime")Integer rewardTime);

    /**
     * 查询铸币流通记录
     * @param page
     * @param req
     * @return
     */
    Page<QueryCirculationListRes> queryCirculationList(@Param("page") Page<QueryCirculationListRes> page, @Param("req") QueryCirculationListReq req);

    /**
     * 铸币加速流通记录
     * @param page
     * @param req
     * @return
     */
    Page<QueryAccelerateListRes> queryAccelerateList(@Param("page") Page<QueryAccelerateListRes> page, @Param("req") QueryAccelerateListReq req);

    /**
     * 铸币发行记录
     * @param page
     * @param req
     * @return
     */
    Page<QueryIssueListRes> queryIssueList(@Param("page") Page<QueryIssueListRes> page, @Param("req") QueryIssueListReq req);

    BigDecimal queryLetokenCirculation(@Param("userId") Integer userId);


    List<AppUserIssue> getWaitRewardList();

    Integer countByUserId(@Param("userId") Integer userId);
    Integer countByUserIdList(@Param("userIdList") List<Integer> userIdList);

    QueryWithdrawHistoryRes queryIssueByUserId(@Param("userId") Integer userId);

    QueryIssueCountRes queryIssueCount();

    List<QueryLineChartRes> queryIssueLineChart(@Param("req") QueryLineChartReq req);


    @Select("select * from app_user_issue where circulation_remain>0")
    List<AppUserIssue> getIssueUserIdList();
}

